

import {axios,get,post,patch,Delete} from './request';

// 解决跨域  (jsonp cors 反向代理 )
// 声明代理对象   这个对象可以代理前端的域名   映射后端的接口地址  



// 所有的接口封装这里  promise (async+await )
// 服务层 提供接口 提供数据
// 反向代理和基路径会有冲突 直接干掉基路径  默认前端的域名 
export const ajax = {
  test:(params)=>get("/api/test",params),
    // test:(params)=>get("http://localhost:2110/test",params),
  findUser:(params)=>get("/api/users",params),
  addUser:(params)=>post("/api/users",params),

  // 发送验证码  http://47.104.209.44:3333/
  // sendCaptcha:params=>get('http://47.104.209.44:3333/captcha/sent',params),

  // verifyCaptcha:params=>get('http://47.104.209.44:3333/captcha/verify',params),

  sendCaptcha:params=>get('/wangyi/captcha/sent',params),

  verifyCaptcha:params=>get('/wangyi/captcha/verify',params),

  // 卖座接口   跨域
  // getMaiData:(params,headers)=>get("https://m.maizuo.com/gateway",params,headers),
  // getMaiData:(params,headers)=>get("/gateway",params,headers),

  // postMaiData:(params,headers)=>post("/gateway",params,headers),

  // 锤子接口
  getChui:(params,headers)=>get("/mobile/new/home?channel_id=1002",params,headers),
  getzi:(params,headers)=>get("/mobile/waterfall?page=1&pageSize=20",params,headers),
  getchuichui:(params,headers)=>get("/mobile/classify",params,headers),
  getshop:(query, headers) => get("/productzzzz/product/spus", query, headers),
  // getshopss:(ids,params)=>get("/mobile/product/spus?ids="+ids,params),

  // 点赞
  getlike:(query)=>get("/api/likes",query),

  addLike:(params)=>post("/api/likes",params),
  delLike:(id)=>Delete("/api/likes/"+id),


  // 购物车
  addshopcar:(params)=>post("/api/shopcar",params),
  //
  getshopcar:(params)=>get("/api/shopcar",params),

  // 修改
  changeshopcar:(id,params)=>patch('/api/shopcar/'+id,params),
  // 删除商品
  delshopcar:(id,params)=>Delete('/api/shopcar/'+id,params),

  // 查询地址
  getsite:(params)=>get("/api/site",params),
  // 添加地址
  addsite:(params)=>post("/api/site",params),

}
